/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sgii;

import java.io.File;
import java.io.IOException;
import java.sql.Statement;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
/**
 *
 * @author Nicolas
 */
public class XlsReader {


/**
 * @author JocLuis
 */

public static void GetrEmployeeRecords(String Location) throws Exception {
        Workbook workbook = Workbook.getWorkbook(new File(Location));
        Sheet sheet = workbook.getSheet(0);
        String educationLevel,gender,employmentDate,category,fullName,employeeId,birthDate;
        String valorCeldaCurso=null;
      // EMPLOYEE_ID	FULL_NAME	CATEGORY	EMPLOYMENT_DATE	BIRTH_DATE	EDUCATION_LEVEL	GENDER
        int i;
       
        for(i=1;i<=503;i++){            
                String sql = "INSERT INTO Employees VALUES(";
                
                employeeId= sheet.getCell(0,i).getContents();//obteniendo valor
                sql += Formatter.getFormattedString(employeeId, Formatter.INTEGER) + ",";
                fullName= sheet.getCell(1,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(fullName, Formatter.STRING) + ",";
                category= sheet.getCell(2,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(category, Formatter.STRING) + ",";
                employmentDate= sheet.getCell(3,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(employmentDate, Formatter.DATE) + ",";
                birthDate= sheet.getCell(4,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(birthDate, Formatter.DATE) + ",";
                educationLevel= sheet.getCell(5,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(educationLevel, Formatter.STRING) + ",";
                gender= sheet.getCell(6,i).getContents();//celda de la columna 7 y fila 1
                sql += Formatter.getFormattedString(gender, Formatter.STRING);
                
                sql += ");";
                
               Statement st = SGII.connection.createStatement();
                System.out.println(sql);
                st.executeUpdate(sql);                             
                                
               
        }
        
         workbook.close();
}

}

